package leetcode9

func isPalindrome(x int) bool {
	if x < 0 || x%10 == 0 && x != 0 {
		return false
	}
	if x <= 9 {
		return true
	}

	left := 0
	for {
		left = left*10 + x%10
		if left == x {
			return true
		}
		x = x / 10
		if left == x {
			return true
		} else if left > x {
			return false
		}
	}
}
